package threadSafe.map;

import java.util.HashMap;
import java.util.Map;
import java.util.function.BiConsumer;


public class MapTest {
	
	private Map map = new HashMap();
	
	public static void main(String[] args) {
		
	}
	public void testMap(){
		System.out.println(Thread.currentThread().getName()+"--");
		setMapValue(map);
		clearMap(map);
		getMapValue(map);
	}
	public void testMap(Map map){
		System.out.println(Thread.currentThread().getName()+"--");
		setMapValue(map);
		clearMap(map);
		getMapValue(map);
	}
	public void setMapValue(Map map){
		map.put("1", "2");
		map.put("2", "3");
		map.put("3", "4");
		map.put("4", "5"); 
	}
	
	public void clearMap(Map map){
		map.remove("1");
	}
	
	public void getMapValue(Map map){
		map.forEach(new BiConsumer(){ 
			@Override
			public void accept(Object t, Object u) {
				System.out.println(t);
				System.out.println(u);
			} 
		});
	}
	
}
